package tech.hypersense.system.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import tech.hypersense.common.core.domain.model.Option;
import tech.hypersense.system.model.bo.UserBO;
import tech.hypersense.system.model.entity.User;
import tech.hypersense.system.model.form.UserForm;
import tech.hypersense.system.model.form.UserProfileForm;
import tech.hypersense.system.model.vo.UserInfoVO;
import tech.hypersense.system.model.vo.UserPageVO;
import tech.hypersense.system.model.vo.UserProfileVO;
import tech.hypersense.system.model.dto.UserImportDTO;


import java.util.List;

/**
 * @Author: HyperSense
 * @CreateTime: 2025-03-27
 * @Description: 用户对象转换器
 * @Version: 1.0
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

    UserPageVO toPageVo(UserBO bo);

    Page<UserPageVO> toPageVo(Page<UserBO> bo);

    UserForm toForm(User entity);

    @InheritInverseConfiguration(name = "toForm")
    User toEntity(UserForm entity);

    @Mappings({
            @Mapping(target = "userId", source = "id")
    })
    UserInfoVO toUserInfoVo(User entity);

    User toEntity(UserImportDTO vo);


    UserProfileVO toProfileVO(UserBO bo);

    User toEntity(UserProfileForm formData);

    @Mappings({
            @Mapping(target = "label", source = "nickname"),
            @Mapping(target = "value", source = "id")
    })
    Option<String> toOption(User entity);

    List<Option<String>> toOptions(List<User> list);
}
